<?php $this->load->view('common/admin_header');?>
<div class="block">
  <div class="block_head">
    <div class="bheadl"></div>
    <div class="bheadr"></div>
    <h2><?=$lang["content_lable_4"]?></h2>
  </div>
  <!-- .block_head ends -->
  <div class="block_content">
    <p class="breadcrumb"><?=$lang['global_lable_14']?> &raquo; <a href="<?=site_url('admins/index')?>"><?=$lang['global_lable_11']?></a> &raquo; <?=$lang['content_lable_1']?> &raquo; <strong><?=$lang["content_lable_4"]?></strong></p>
    <?php $this->load->view('common/notify');?>
    <form action="<?=site_url('admins/products')?>" method="get">
      <input type="hidden" name="field" value="<?=isset($field)?$field:'n.update_time'?>" id="field">
      <input type="hidden" name="sort" value="<?=isset($sort)?$sort:'asc'?>" id="sort">
      <table cellpadding="0" cellspacing="0" width="100%" class="sortable">
        <thead>
          <tr>
            <th><input type="checkbox" name="chk_all" id="chk_all"></th>
            <th><?=$lang["content_lable_10"]?></th>
            <th><a id="nd.title" class="<?=isset($field) && $field=='nd.title'?$sort:'';?>" href="#"><?=$lang['global_lable_15']?></a></th>
            <th><a id="n.category_id" class="<?=isset($field) && $field=='n.category_id'?$sort:'';?>" href="#"><?=$lang["content_lable_3"]?></a></th>
            <th><a id="n.status" class="<?=isset($field) && $field=='n.status'?$sort:'';?>" href="#"><?=$lang['global_lable_16']?></a></th>
            <th><a id="n.sort_order" href="#" class="<?=isset($field) && $field=='n.sort_order'?$sort:'';?>"><?=$lang['global_lable_17']?></a></th>
            <th><a id="n.add_time" class="<?=isset($field) && $field=='n.add_time'?$sort:'';?>" href="#"><?=$lang['global_lable_18']?></a></th>
            <th><a id="n.update_time" class="<?=isset($field) && $field=='n.update_time'?$sort:'';?>" href="#"><?=$lang['global_lable_19']?></a></th>
            <th style="text-align:center"><?=$lang['global_lable_21']?></th>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td><input type="text" class="stext" name="title" lang="zh-TW" x-webkit-speech x-webkit-grammar="bUIltin:search" value="<?=isset($title)?$title:''?>"></td>
            <td>
              <select name="category_id" id="category_id">
               <option value=""><?=$lang["content_lable_21"]?></option>
               <?php if(!empty($categorys)):?>
               <?php foreach ($categorys as $ctg):?>
               <option value="<?php echo $ctg['id']; ?>" <?=set_select('category_id',$ctg['id'])?> <?=isset($category_id) && $category_id==$ctg['id']?'selected':''?> ><?php echo $ctg['title']; ?></option>
               <?php endforeach; ?>
               <?php endif;?>
              </select>
            </td>
            <!-- <td>&nbsp;</td> -->
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td style="text-align:center">
              <input type="submit" class="btn btn-small btn-primary" name="sub_filter" value="<?=$lang["global_lable_22"]?>"/>
              <a href="<?=site_url('admins/products/add')?>" class="btn btn-small btn-danger"><i class="icon-plus"></i> <?=$lang["global_lable_23"]?></a>
            </td>
          </tr>
        </thead>
        <tbody class="table">
          <?php if(isset($lists_count) && $lists_count>0):?>
          <?php foreach($lists->result_array() as $list):
            $urls=site_url('admins/products/%s/'.$list['id']);
            $thumb_img=!empty($list['main_image']) && file_exists($list['main_image'])?Imagelib::resize_thumb($list['main_image'],80,80):'themes/admins/img/noimage.png';
            $status=$list['status']==1?$lang['global_lable_37']:$lang['global_lable_38'];
          ?>
          <tr>
            <td><input type="checkbox" class="chk_one"  value="<?=$list['id']?>"></td>
            <td><img src="<?=base_url().$thumb_img?>" width="80"/></td>
            <td title="<?=$list['title']?>"><?=mb_substr($list['title'],0,20,'utf-8')?>
              <?php if(mb_strlen($list['title'])>20) echo '...';?></td>
            <td><?=$list['ncd_title']; ?></td>
            <td><?=$status?></td>
            <td><?=$list['sort_order']?></td>
            <td><?=date($format_time,$list['add_time'])?></td>
            <td><?=date($format_time,$list['update_time'])?></td>
            <td class="listaction">
              <a href="<?=sprintf($urls,"edit");?>" class="l_edit"><?=$lang['global_lable_24']?></a>
              <a href="javascript:void(0);" onClick="delete_item('<?=sprintf($urls,"delete")?>');" class="l_delete"><?=$lang['global_lable_25']?></a>
            </td>
          </tr>
          <?php endforeach;?>
          <?php else:?>
          <tr>
            <td colspan="19" class="nodata"><p><?=$lang['global_lable_42']?></p></td>
          </tr>
          <?php endif;?>
        </tbody>
      </table>
      <p>
        <input type="button" class="btn btn-small" onclick="delete_allitem('<?=site_url('admins/products/delete_batch')?>')" value="<?=$lang['global_lable_28']?>"/>
      </p>
      <!-- .tableactions ends -->
      <div id="pagination"><?php echo $pagination;?><div class="listscount"><?=$lang['global_lable_29']?> <?=$lists_count?> <?=$lang['global_lable_30']?></div></div>
      <!-- .pagination ends -->
    </form>
  </div>
  <!-- .block_content ends -->
  <div class="bendl"></div>
  <div class="bendr"></div>
</div>
<!-- .block ends -->
<?php $this->load->view('common/admin_footer');?>
